extends Area2D

var speed = 40
var health = 100
@onready var body = $'body'
@onready var bucket = $'bucket'
@onready var left_arm = $'left_arm'
@onready var right_arm = $'right_arm'
var spawn_number: int
var walk_token = false
var push_speed = 0
var on_ground = false

func _ready():
	var anime_name = ["idle1", "idle2"][randi() % 2]
	for part in [body, bucket, left_arm, right_arm]:
		part.play(anime_name)
	$walk_timer.start()

func wound(damage, push=0):
	health -= damage
	if health <= 0:
		get_parent().zombie_list.erase(self)
		queue_free()
	elif push > 0:
		push_speed += push

func _process(delta):
	if position.x <= 1760:
		on_ground = true

#func _physics_process(delta):
	#if not is_on_floor():
		#velocity.y += gravity
	#if walk_token:
		#for part in [body, bucket, left_arm, right_arm]:
			#part.play("walk1")
			#velocity.x = -1 * speed
			#if push_speed > 0:
				#velocity.x += push_speed
				#push_speed -= get_parent().friction
	#move_and_slide()

func _on_timer_timeout():
	walk_token = true


#func _on_area_entered(area):
	#print('entered')
